#define quickread
#ifdef quickread
#include <cstdio> 
template <typename T>
inline void read(T& x)
{
    int c=getchar(), f=1; x=0;
    while(c<'0'||'9'<c) {if(c=='-') f=-1; c=getchar();}
    while('0'<=c&&c<='9') 
        x=(x<<3)+(x<<1)+c-'0', c=getchar();
    x*=f;
}
template <typename T>
inline void quickwrite(T x)
{
    if(x<0) putchar('-'), x*=-1;
    if(x>=10) quickwrite(x/10);
    putchar(x%10+'0');
}
#else 
#include <iostream>
#endif
#include <algorithm>
#include <queue>
using namespace std;
#define DEBUG
const int N=1e6+10;
using PII=pair<int, int>;
#define x first
#define y second
PII ranges[N];
priority_queue<int, vector<int>, greater<int>> heap;
int n;

void init()
{
    while(!heap.empty()) heap.pop();
    read(n);
    for(int i=0; i<n; i++)
    {
        int op, x, y; read(op); read(x);
        if(op==1)
            ranges[i]={x, n-1};
        else if(op==2)
            ranges[i]={0, x};
        else if(op==3)
        {
            read(y);
            ranges[i]={x, y};
        }
    }

    sort(ranges, ranges+n);
    // for(int i=0; i<n; i++)
    //     printf("ranges[%d]:{%d, %d}\n", i, ranges[i].x, ranges[i].y);
}

void solve()
{
    init();

    int cur=0; //ranges[]下标
    for(int i=0; i<n; i++) //枚举每一个可用位置
    {
        while(cur<n&&ranges[cur].x<=i)
        {
            heap.push(ranges[cur].y); cur++;
        }
        //无可用位置 || 当前枚举位置超出范围
        if(heap.empty()||i>heap.top()) {puts("N"); return;}
        heap.pop(); //使用位置i
    }
    puts("Y");
}

// #undef DEBUG
signed main()
{
    #ifdef DEBUG
        freopen("./in.txt", "r", stdin);
        freopen("./out.txt", "w", stdout);
    #endif
    #ifndef quickread
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    #endif

    int T=1; scanf("%d", &T);
    while(T--) 
    {
        solve();
    }
    return 0;
}
